//
//  CityBrandViewController.m
//  cityStar
//
//  Created by wangjia on 14/12/14.
//  Copyright (c) 2014年 tiny. All rights reserved.
//

#import "CityBrandViewController.h"
#import "BranddetailsViewController.h"
#import "CityBrandList.h"
#import "HTDefine.h"
#import "WaresDetailViewController.h"
#import "HWSearchViewController.h"

@interface CityBrandViewController ()

@end

@implementation CityBrandViewController
@synthesize oneTableCell,TwoTableCell,ThreeTableCell;

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.navigationItem.title = @"品牌商城";
    self.tableView.sectionFooterHeight = 0;
    self.tableView.sectionHeaderHeight = 0;
    
    UIButton * regBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 20, 20)];
    regBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentRight;
    [regBtn setTitleColor:rgba(133, 133, 133, 1) forState:UIControlStateHighlighted];
    [regBtn setImage:[UIImage imageNamed:@"bsearch"] forState:UIControlStateNormal];
    [regBtn setImage:[UIImage imageNamed:@"bsearch_touch"] forState:UIControlStateHighlighted];
    [regBtn addTarget:self action:@selector(searchAction) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem * iHaveNewsBtnItem = [[UIBarButtonItem alloc]initWithCustomView:regBtn];
    self.navigationItem.rightBarButtonItem = iHaveNewsBtnItem;
    
    UIView *viewd = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 90, 30)];
    UIButton *leftButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [leftButton setFrame:CGRectMake(-30, 0, 90, 30)];
    [leftButton setTitle:@"返回" forState:UIControlStateNormal];
    leftButton.titleLabel.font = [UIFont systemFontOfSize:15];
    [leftButton setTitleColor:[UIColor colorWithWhite:0.200 alpha:1.000] forState:UIControlStateNormal];
    [leftButton setTitleColor:[UIColor colorWithRed:0.991 green:0.532 blue:0.303 alpha:1.000] forState:UIControlStateHighlighted];
    [leftButton addTarget:self action:@selector(back) forControlEvents:UIControlEventTouchUpInside];
    [leftButton setImage:[UIImage imageNamed:@"back"] forState:UIControlStateNormal];
    [leftButton setImage:[UIImage imageNamed:@"back_touch"] forState:UIControlStateHighlighted];
    
    [viewd addSubview:leftButton];
    
    UIBarButtonItem *barButtonItem = [[UIBarButtonItem alloc] initWithCustomView:viewd];
    self.navigationItem.leftBarButtonItem = barButtonItem;
}

-(void)searchAction
{
    HWSearchViewController *hwSearchViewController = [[HWSearchViewController alloc]init];
    hwSearchViewController.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:hwSearchViewController animated:YES];
}

-(void)back
{
    [self.navigationController popViewControllerAnimated:YES];
}
-(void)viewWillAppear:(BOOL)animated
{
    if ([[[UIDevice currentDevice] systemVersion] floatValue] >=7.0) {
        self.navigationController.navigationBar.translucent = NO; //禁止半透明毛玻璃效果
        self.navigationController.navigationBar.tintColor = kWhiteNavTitleColor; //返回按钮颜色
        self.navigationController.navigationBar.barTintColor = [UIColor whiteColor]; //bar背景颜色
        self.navigationController.navigationBar.titleTextAttributes = @{NSForegroundColorAttributeName:kWhiteNavTitleColor,NSFontAttributeName:[UIFont boldSystemFontOfSize:18]}; //标题颜色
        self.navigationController.navigationBar.barStyle = UIBarStyleDefault;
    }else{
        [self.navigationController.navigationBar setTintColor:[UIColor whiteColor]]; //bar背景颜色
        self.navigationController.navigationBar.translucent = NO;
        self.navigationController.navigationBar.titleTextAttributes = @{NSForegroundColorAttributeName:kWhiteNavTitleColor,NSFontAttributeName:[UIFont boldSystemFontOfSize:18]};
        self.navigationController.navigationBar.barStyle = UIBarStyleDefault;
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - 按钮方法
//图片
- (IBAction)ProductdetailsAction:(id)sender {
    BranddetailsViewController *BrandViewController = [[BranddetailsViewController alloc] init];
    [self.navigationController pushViewController:BrandViewController animated:true];
}

- (IBAction)goodsdetail_Action:(id)sender {
    WaresDetailViewController *waresDetailViewController = [[WaresDetailViewController alloc] init];
    [self.navigationController pushViewController:waresDetailViewController animated:true];
}

//更多
-(IBAction)pushToCityBrandListAction:(id)sender{

    UIButton *btn = (UIButton *)sender;
    CityBrandList *ListViewController = [[CityBrandList alloc] init];
    if(btn.tag == 1)
    {
        ListViewController.title = @"本地精品";
    }else if(btn.tag == 2)
    {
        ListViewController.title = @"品质潮品";
    }else{
        ListViewController.title = @"至尚秦品";
    }
    
    [self.navigationController pushViewController:ListViewController animated:true];
}

#pragma mark -tableViewdelegate


- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return 10;
}


#pragma mark -tableViewdataSource
//- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
//{
//    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"reuseIdentifier" forIndexPath:indexPath];
//    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
//
//    return cell;
//
//}

@end
